import time


def bubble_sort(arr):
	none_sorted_flag = True

	for i in range(len(arr)-1):
		for j in range(len(arr)-1-i):
			if arr[j] > arr[j+1]:
				arr[j], arr[j+1] = arr[j+1], arr[j]
				none_sorted_flag = False
		if none_sorted_flag:
			return arr
		none_sorted_flag = True

	return arr


file_names = ["m1_sorted.txt", "m2_reverse.txt", "m3_shuffle.txt"]
for file_name in file_names:
	arr = []
	with open(file_name, 'r') as f:
		for line in f.readlines():
			arr.append(int(line))
	
	start_time = time.time()
	arr = bubble_sort(arr)
	end_time = time.time()

	print(file_name[:-4], (end_time - start_time) * 1000, "milliseconds")

